package com.woniuxy.springparking.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.springparking.common.RestResult;
import com.woniuxy.springparking.dao.OverOrderDao;
import com.woniuxy.springparking.dao.PreOrderDao;
import com.woniuxy.springparking.pojo.OverOrder;
import com.woniuxy.springparking.pojo.PreOrder;
import com.woniuxy.springparking.service.OrderService;
import com.woniuxy.springparking.vo.OverOrderVo;
import com.woniuxy.springparking.vo.PerOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private PreOrderDao preOrderDao;
    @Autowired
    private OverOrderDao overOrderDao;
    @Override
    public RestResult findPerOderByPage(PerOrderVo pvo) {
        Page<Object> pages= PageHelper.startPage(pvo.getPage(),pvo.getLimit());
        List<PreOrder> data=preOrderDao.selectPOrderByPage(pvo);
        return new RestResult(pages.getTotal(),data);
    }

    @Override
    public RestResult findOverOderByPage(OverOrderVo ovo) {
        Page<Object> pages= PageHelper.startPage(ovo.getPage(),ovo.getLimit());
        List<OverOrder> data=overOrderDao.selectOverOrderByPage(ovo);
        return new RestResult(pages.getTotal(),data);
    }

    @Override
    public String findPlatenum(Integer pu_id) {
        return preOrderDao.selectPlatenum(pu_id);
    }

    @Override
    public Double findMuPrice(Integer mu_id) {
        return preOrderDao.selectMuPrice(mu_id);
    }

    @Override
    public Double findPuPrice(Integer pu_id) {
        return preOrderDao.selectStallPrice(pu_id);
    }

    @Override
    public String findPrNum(Integer orderId) {
        return overOrderDao.selectPernum(orderId);
    }
}
